home *** CD-ROM | disk | FTP | other *** search
- Path: po.CWRU.Edu!mab22
- From: mab22@po.CWRU.Edu (Michael A. Balfour)
- Newsgroups: comp.lang.c
- Subject: Re: Character String --> Integer
- Date: 9 Feb 1996 16:01:18 GMT
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Message-ID: <4ffr4e$4ji@madeline.INS.CWRU.Edu>
- References: <4fb0ga$lsa@remus.rutgers.edu>
- Reply-To: mab22@po.CWRU.Edu (Michael A. Balfour)
- NNTP-Posting-Host: kanga.ins.cwru.edu
-
-
- In a previous article, wempa@remus.rutgers.edu (Force Of Nature) says:
-
- >Is there an easy way to convert a character string such as '2425' to the
- >integer 2425 ??? The only way I can think of is to pick off characters
- >one at a time and use switch statements to determine the value (0-9) and
- >then multiply by the correct power of 10. Is there an easier way to do
- >this ???????
- >
- >
-
- Just to throw a tiny spin on the discussion, if you don't know if the
- character set for the string matches the native character set (i.e.
- EBCDIC string on an ASCII machine), you can't use the standard library
- functions. But rather than use a switch statement, you can LOGICAL AND
- each character with 0x0F. It'll save you a little time anyways.
-
- Mike Balfour
-
- --
- ----------------------------------+--------------------------------
- Mike Balfour, Partner | BS/MS Candidate - ECMP
- Overload Engineering | Case Western Reserve University
- "New Ideas for a Brighter Future" | Cleveland, OH
-